package cn.cxq.learning.e1_3;

import static java.lang.Math.cos;
import static java.lang.Math.sin;

public class EffectiveValueUtil {

    private static double PI = 3.1415926535897932;

    public static void operation() {

        double x, deltx = 0.25 * PI;
        x = 0.5 * PI - deltx;
        test(deltx, x);

        System.out.println("---------------------------------------");

        deltx *= 1.0e-8;
        x = 0.5 * PI - deltx;
        test(deltx, x);
    }

    private static void test(double deltx, double x) {
        double y1, y2, y3, y4;
        y1 = sin(deltx);
        y2 = cos(x);
        y3 = cos(deltx);
        y4 = sin(x);
        System.out.println(String.format("y1 =%22.15e", y1));
        System.out.println(String.format("y2 =%22.15e", y2));
        System.out.println(String.format("y3 =%22.15e", y3));
        System.out.println(String.format("y4 =%22.15e", y4));
    }
}
